package com.group.sliding.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.group.sliding.domain.dto.OrderItemDTO;
import com.group.sliding.domain.po.Item;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ItemMapper extends BaseMapper<Item> {

    @Update("UPDATE item SET stock = stock - #{num}, sold = sold + #{num}, update_time = now() WHERE id = #{itemId}")
    void updateStockAndSold(OrderItemDTO orderDetail);
}
